const app = getApp();
const Api = app.globalData.Api;
const wxApi = app.globalData.wxApi;
const util = app.globalData.util;
Page({
  data: {
    video: {}
  },
  onLoad( options ) {
    this.init( options );
    wxApi.setNavTitle(this.data.video.title);
  }, 
  init( options ) {
    this.loadVideo( options.id );
    
  },
  loadVideo( id ) {
    // let video = util.decodeURI( videoURI );
    // video.dateTime = util.dateFormat( null, video.createTime );
    Api.getVideoDetail(id, (video) => {
      console.log(video)
      video.dateTime = util.dateFormat( null, video.createTime );
      this.setData({
        video: video
      })
    })
    
  },
  likesClick() {
    let video = this.data.video;
    Api.memoryVideoLikes(video.id, (res, code) => {
      console.log('video.......')
      console.log( res );
      console.log(code);
    })
  },
  onSubedOption() {
    let video = this.data.video;
    video.name = video.title;
    video.ordersCount = video.orders;
    video = util.encodeURI( video );
    let path = '../common/buy-goods/buy-goods'
    wxApi.navigateTo(path, {
      data: video,
      type: 1
    });
  }
}) 